package com.example.agrigreennewssys.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Value("${uploadPath}")
    private String uploadPath;

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 只要地址是 /api/upload/editorImage/** 开始，就会被拦截
//        System.out.println("拦截器启动");
//
//    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射虚拟路径
        registry.addResourceHandler("/upload/**").addResourceLocations( "file:"+uploadPath);
    }

}